import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Before;

import java.io.IOException;
import java.io.InputStream;


/**
 * Created by webrx on 2017/6/15.
 */
public class Dome {
    protected SqlSession ss;
    protected SqlSessionFactory sf;
    @Before
    public void init(){
        InputStream inputStream=null;
        try {
            inputStream = Resources.getResourceAsStream("mybatis-config.xml");
        } catch (IOException e) {
            e.printStackTrace();
        }
        sf= new SqlSessionFactoryBuilder().build(inputStream);
        ss =sf.openSession();
    }

   /* @Test
    public void show(){
        BookMapper book = ss.getMapper(BookMapper.class);
       Book bo = new Book();
       *//* bo.setName("小强");
        bo.setPrice(59);
        book.save01(bo);
        ss.commit();*//*
        book.update("海鸟",4);
        ss.commit();

        Map<String,Object> map = new HashMap<String,Object>();
        map.put("name","小鸟");
        map.put("price",100);
        book.addBook(map);
        ss.commit();

        book.deleteById(3);
        ss.commit();

    }*/
}
